<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/layui/layui_2/layui/css/layui.css"
	media="all">
</head>
<body>
<br/>
	<table class="layui-table" id="dept" lay-filter="dept_table"></table>
	<script src="${pageContext.request.contextPath }/layui/layui_2/layui/layui.js"></script>
	<script>
		layui.use(['form','element','jquery','table','layer'], function() {
			var form = layui.form,
				element = layui.element,
				$ = layui.jquery,
				table = layui.table,
				layer = layui.layer;
			
			var cols = [ [ {
				field : 'p_id',
				align : 'center',
				title : '编号',
				width : 280
			}, {
				field : 'p_name',
				id : 'pName',
				align : 'center',
				title : '部门名称',
				width : 420
			}, {
				field : 'p_remark',
				align : 'center',
				title : '部门备注',
				width : 600
			}, {
				title : '还原部门',
				align : 'center',
				toolbar : '#restore',
				width : 400
			} ] ];
			
			//方法级渲染
			table.render({
				elem : '#dept',
				url : '${pageContext.request.contextPath }/deptAction_findByPage1',
				cols : cols,
				id : 'testReload',
				limit: 10,
			    limits: [10, 30, 50],
				page : true
			});
			
			//监听工具条
			table.on('tool(dept_table)', function(obj){
			    var data = obj.data;
			    if(obj.event === 'restore'){
			      layer.confirm('你确定要还原“'+data.p_name+'”吗', {title:"还原确定"}, function(index){
			          location.href = "${pageContext.request.contextPath}/deptAction_restore?p_id=" + data.p_id;
			          layer.close(index);
			      });
			     } else if(obj.event === 'edit'){
			     
			     }
			 });
		})
		
	</script>
	<script type="text/html" id="restore">
    	<a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="restore"><i class="layui-icon">&#xe618;</i>还原</a>
	</script>
</body>
</html>